<?php


namespace App\Supports\Util;


class PrintMessage
{

    protected $printMessage;

    /**
     * 获取打印信息
     * @return string
     */
    public function getPrintMessage()
    {
        return $this->printMessage;
    }

    /**
     * 获取打印信息 nl2br格式
     * @return string
     */
    public function getPrintMessageNl2br()
    {
        return nl2br($this->printMessage);
    }

    /**
     * 添加打印信息
     * @param $message
     * @param $throwable
     */
    public function addPrintMessage($message, \Throwable $throwable = null)
    {
        $this->printMessage .= $message . PHP_EOL;
        if ($throwable && env('APP_DEBUG')) {
            $this->printMessage .= $throwable->getTraceAsString();
        }
    }
}